-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass responses appropriately to errors (swaggerpy) #158
Conversation
@@ -26,9 +26,13 @@ def handle_response_errors(e): | |||
:raises HTTPError: :class: `swaggerpy.exception.HTTPError` | |||
""" | |||
args = list(e.args) | |||
kwargs = {} | |||
if hasattr(e, 'response') and hasattr(e.response, 'text'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there value in setting kwargs['response']
even though e.response.text
doesn't exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, yeah, definitely. fixed
8d07f5d
to
e35602d
Compare
try: | ||
handle_response_errors(error) | ||
except HTTPError as e: | ||
self.assertEqual(e.json, {'foo': 'bar'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is e.json
getting set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that was from previous diff where I had added that as a property to exception. Fixed <3
lgtm would be good to have @prat0318 give it a once over since he is more familiar with the codebase. |
e35602d
to
8b56705
Compare
except HTTPError as e: | ||
self.assertEqual(e.response.json(), {'foo': 'bar'}) | ||
self.assertEqual(e.response, response) | ||
self.assertEqual(e.request, request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if there is a test already that '400 Bad Request' is contained in the e
's args, will be good to add it if not present already.
lgtm |
Pass responses appropriately to errors (swaggerpy)
Fixes #156 , the main issue being that we actually weren't passing responses to exceptions properly.
e.json might make a good convenience method, but I skipped it for now (e.response.json is a good substitute. But documenting this at some point would be good)